<?php


/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024-03-12 09:42
 * +-------------------------------------------------------------
 */

use app\service\middleware\CheckDomain;
use think\facade\Route;
use app\service\middleware\LoginLimit;
use app\service\middleware\Token;

//登录
Route::group('login', function () {
    Route::post('login', 'login/login');//登录
//    Route::post('login', 'login/login')->middleware(LoginLimit::class);//登录
    Route::get('captcha', 'login/captcha');//验证码
});

//首页
Route::group('stat', function () {
    Route::post('list', 'Stat/list');//统计
})->middleware(Token::class);

//数据看板
Route::group('board', function () {
    Route::post('warehouse_overview', 'board.index/warehouseOverview');//统计
    Route::post('warehouse_detail', 'board.index/warehouseDetail');//仓库明细
    Route::post('warehouse_warning', 'board.index/warehouseWarning');//仓库预警
    Route::post('goods_sales', 'board.index/goodsSales');//商品销售统计
    Route::post('store_sales', 'board.index/StoreSales');//门店销售统计
    Route::post('store_detail', 'board.index/storeDetail');//门店明细
    Route::post('store_growth', 'board.index/storeGrowth');//门店增长量
    Route::post('salesman_ranking', 'board.index/salesmanRanking');//业务员销售额排名
    Route::post('salesman_area_sales', 'board.index/salesmanAreaSales');//业务员区域销售额
    Route::post('map', 'board.index/map');//数字化地图
    Route::post('store_goods_sales', 'board.index/storeGoodsSales');//门店商品热销排行
    Route::post('deliver_money', 'board.index/deliverMoney');//每日配送金额统计
    Route::post('deliver_overview', 'board.index/deliverOverview');//配送概况
    Route::post('day', 'board.index/dayStat');//日统计
    Route::post('month', 'board.index/monthStat');//月统计
    Route::post('quarter', 'board.index/quarterStat');//季度统计
    Route::post('year', 'board.index/yearStat');//年统计
    Route::post('collection', 'board.index/collectionStat');//回款统计
    Route::post('collection_data', 'board.index/collectionData');//回款数据

})->middleware(Token::class);
//公司用户
Route::group('user', function () {
    Route::post('list', 'CompanyUser/list');//列表
    Route::post('create', 'CompanyUser/add');//添加
    Route::post('modify', 'CompanyUser/edit');//修改
    Route::post('details', 'CompanyUser/detail');//详情
    Route::post('modify_status', 'CompanyUser/editStatus');//修改状态
    Route::post('del', 'CompanyUser/del');//删除
    Route::post('select', 'CompanyUser/search');//查询

    //角色
    Route::group('role', function () {
        Route::post('list', 'CompanyRole/list');//列表
        Route::post('create', 'CompanyRole/add');//添加
        Route::post('modify', 'CompanyRole/edit');//修改
        Route::post('details', 'CompanyRole/detail');//详情
        Route::post('modify_status', 'CompanyRole/editStatus');//修改状态
        Route::post('del', 'CompanyRole/del');//删除
        Route::post('select', 'CompanyRole/search');//查询
    });
    //菜单
    Route::group('menu', function () {
        Route::post('list', 'CompanyMenu/list');//列表
        Route::post('create', 'CompanyMenu/add');//添加
        Route::post('modify', 'CompanyMenu/edit');//修改
        Route::post('details', 'CompanyMenu/detail');//详情
        Route::post('modify_status', 'CompanyMenu/editStatus');//修改状态
        Route::post('del', 'CompanyMenu/del');//删除
        Route::post('select', 'CompanyMenu/search');//查询
    });
})->middleware(Token::class);


//采购订单
Route::group('order', function () {
    Route::post('list', 'CompanyOrder/list');//列表
    Route::post('create', 'CompanyOrder/add');//添加
    Route::post('modify', 'CompanyOrder/edit');//修改
    Route::post('details', 'CompanyOrder/detail');//详情
    Route::post('modify_status', 'CompanyOrder/editStatus');//修改状态
    Route::post('del', 'CompanyOrder/del');//删除
    Route::post('select', 'CompanyOrder/search');//查询
    Route::post('goods', 'CompanyOrder/goodsList');//商品列表
    Route::post('cate', 'CompanyOrder/cateList');//商品分类列表
    Route::get('sign', 'CompanyOrder/editStatus')->append(['order_status' => 3]);//签收
    Route::get('put', 'CompanyOrder/editStatus')->append(['order_status' => 5]);//上架
})->middleware(Token::class);

//订单明细
Route::group('order_detail', function () {
    Route::post('modify', 'CompanyOrderDetail/edit');//修改
})->middleware(Token::class);


//第三方
Route::group('supplier', function () {
    Route::post('list', 'Supplier/list');//列表
    Route::post('create', 'Supplier/add');//添加
    Route::post('modify', 'Supplier/edit');//修改
    Route::post('details', 'Supplier/detail');//详情
    Route::post('modify_status', 'Supplier/editStatus');//修改状态
    Route::post('del', 'Supplier/del');//删除
    Route::post('select', 'Supplier/search');//查询
})->middleware(Token::class);
//第三方用户
Route::group('supplier_user', function () {
    Route::post('select', 'SupplierUser/search');//查询
})->middleware(Token::class);

//仓库
Route::group('warehouse', function () {
    Route::post('list', 'Warehouse/list');//列表
    Route::post('create', 'Warehouse/add');//添加
    Route::post('modify', 'Warehouse/edit');//修改
    Route::post('details', 'Warehouse/detail');//详情
    Route::post('modify_status', 'Warehouse/editStatus');//修改状态
    Route::post('del', 'Warehouse/del');//删除
    Route::post('select', 'Warehouse/search');//查询
    //库区
    Route::group('area', function () {
        Route::post('list', 'WarehouseArea/list');//列表
        Route::post('create', 'WarehouseArea/add');//添加
        Route::post('modify', 'WarehouseArea/edit');//修改
        Route::post('details', 'WarehouseArea/detail');//详情
        Route::post('modify_status', 'WarehouseArea/editStatus');//修改状态
        Route::post('del', 'WarehouseArea/del');//删除
        Route::post('select', 'WarehouseArea/search');//查询
    });
    //库位
    Route::group('storage', function () {
        Route::post('list', 'WarehouseStorage/list');//列表
        Route::post('create', 'WarehouseStorage/add');//添加
        Route::post('modify', 'WarehouseStorage/edit');//修改
        Route::post('details', 'WarehouseStorage/detail');//详情
        Route::post('modify_status', 'WarehouseStorage/editStatus');//修改状态
        Route::post('del', 'WarehouseStorage/del');//删除
        Route::post('select', 'WarehouseStorage/search');//查询
        Route::post('move', 'WarehouseStorage/edit');//移位
        Route::post('modify_group', 'WarehouseStorage/modifyGroup');//移位列表
    });
    //商品
    Route::group('goods', function () {
        Route::post('list', 'CompanyOrderStorage/list');//库位商品列表
    });
    //出入库记录
    Route::group('storage_log', function () {
        Route::post('list', 'WarehouseStorageGoodsLogs/list');//列表
    });
    //盘点
    Route::group('stock', function () {
        Route::post('list', 'WarehouseTakeStock/list');//列表
        Route::post('create', 'WarehouseTakeStock/add');//添加
        Route::post('details', 'WarehouseTakeStock/detail');//详情
//        Route::get('start', 'WarehouseTakeStock/editStatus')->append(['stock_status' => 2]);//开始盘点
        Route::get('audit', 'WarehouseTakeStock/editStatus')->append(['stock_status' => 2]);//提交审核
        Route::get('pass', 'WarehouseTakeStock/editStatus')->append(['stock_status' => 3]);//通过
        Route::get('reject', 'WarehouseTakeStock/editStatus')->append(['stock_status' => 4]);//拒绝
        Route::post('del', 'WarehouseTakeStock/del');//删除
        Route::post('select', 'WarehouseTakeStock/search');//查询
    });
    //盘点明细
    Route::group('stock_goods', function () {
        Route::post('list', 'WarehouseTakeStockGoods/list');//列表
        Route::get('modify', 'WarehouseTakeStockGoods/editStatus');//开始盘点
    });
})->middleware(Token::class);

//商品
Route::group('goods', function () {
    Route::post('list', 'CompanyGoods/list');//列表
    Route::post('modify', 'CompanyGoods/edit');//修改
    Route::post('details', 'CompanyGoods/detail');//详情
    Route::post('modify_status', 'CompanyGoods/editStatus');//修改状态
    Route::post('del', 'CompanyGoods/del');//删除
    Route::post('select', 'CompanyGoods/search');//查询
    Route::post('store', 'CompanyGoods/goodsStore');//公司-商品-门店列表
    Route::post('bind', 'CompanyGoods/goodsBindStore');//公司-商品-绑定门店
    Route::group('cate', function () {
        Route::post('list', 'GoodsCate/list');//分类列表
        Route::post('select', 'GoodsCate/search');//查询
    });

})->middleware(Token::class);


//门店
Route::group('store', function () {
    Route::post('list', 'Store/list');//列表
    Route::post('create', 'Store/add');//添加
    Route::post('modify', 'Store/edit');//修改
    Route::post('details', 'Store/detail');//详情
    Route::post('modify_status', 'Store/editStatus');//修改状态
    Route::post('del', 'Store/del');//删除
    Route::post('select', 'Store/search');//查询
    Route::post('download_template', 'Store/downloadTemplate');//模版下载
    Route::post('import', 'Store/import');//导入
    Route::post('import_excel','Store/importExcel'); //表格导入
    //门店用户
    Route::group('user', function () {
        Route::post('list', 'StoreUser/list')->append(['is_salesman' => '2']);//列表
        Route::post('create', 'StoreUser/add')->append(['is_salesman' => '2']);//添加
        Route::post('modify', 'StoreUser/edit');//修改
        Route::post('details', 'StoreUser/detail');//详情
        Route::post('modify_status', 'StoreUser/editStatus');//修改状态
        Route::post('del', 'StoreUser/del');//删除
        Route::post('select', 'StoreUser/search')->append(['is_salesman' => '2']);//查询
    });
    //门店业务员
    Route::group('sales', function () {
        Route::post('list', 'StoreUser/list')->append(['is_salesman' => '1']);//列表
        Route::post('create', 'StoreUser/add')->append(['is_salesman' => '1']);//添加
        Route::post('modify', 'StoreUser/edit');//修改
        Route::post('details', 'StoreUser/detail');//详情
        Route::post('modify_status', 'StoreUser/editStatus');//修改状态
        Route::post('del', 'StoreUser/del');//删除
        Route::post('select', 'StoreUser/search')->append(['is_salesman' => '1']);//查询
        Route::post('download_template', 'StoreUser/downloadTemplate');//模版下载
        Route::post('import', 'StoreUser/import');//导入
    });
    //用户银行卡信息
    Route::group('bank', function () {
        Route::post('list', 'StoreUserBank/list');//列表
        Route::post('create', 'StoreUserBank/add');//添加
        Route::post('modify', 'StoreUserBank/edit');//修改
        Route::post('details', 'StoreUserBank/detail');//详情
        Route::post('modify_status', 'StoreUserBank/editStatus');//修改状态
        Route::post('del', 'StoreUserBank/del');//删除
        Route::post('select', 'StoreUserBank/search');//查询
    });

    //门店销售订单
    Route::group('order', function () {
        Route::post('list', 'StoreOrder/list');//列表
        Route::post('modify', 'StoreOrder/edit');//修改
        Route::post('details', 'StoreOrder/detail');//详情
        Route::post('modify_status', 'StoreOrder/editStatus');//修改状态
        Route::get('send_out', 'StoreOrder/editStatus')->append(['order_status' => 3]);//发货
        Route::get('cancel', 'StoreOrder/editStatus')->append(['order_status' => 6]);//门店取消订单
        Route::get('confirm', 'StoreOrder/editStatus')->append(['order_status' => 4]);//门店确认收货
        Route::post('del', 'StoreOrder/del');//删除
        Route::post('select', 'StoreOrder/search');//查询
        Route::post('profit', 'StoreOrder/profit');//分账列表
        Route::post('import_excel','StoreOrder/importExcel'); //表格订单导入
    });
})->middleware(Token::class);


//物流管理
Route::group('deliver', function () {
    //车辆管理
    Route::group('car', function () {
        Route::post('list', 'DeliverCar/list');//列表
        Route::post('create', 'DeliverCar/add');//创建
        Route::post('modify', 'DeliverCar/edit');//修改
        Route::post('details', 'DeliverCar/detail');//详情
        Route::post('modify_status', 'DeliverCar/editStatus');//修改状态
        Route::post('del', 'DeliverCar/del');//删除
        Route::post('select', 'DeliverCar/search');//查询
    });
    //司机管理
    Route::group('driver', function () {
        Route::post('list', 'DeliverDriver/list');//列表
        Route::post('create', 'DeliverDriver/add');//创建
        Route::post('modify', 'DeliverDriver/edit');//修改
        Route::post('details', 'DeliverDriver/detail');//详情
        Route::post('modify_status', 'DeliverDriver/editStatus');//修改状态
        Route::post('del', 'DeliverDriver/del');//删除
        Route::post('select', 'DeliverDriver/search');//查询
    });
    //路线管理
    Route::group('line', function () {
        Route::post('list', 'DeliverLine/list');//列表
        Route::post('create', 'DeliverLine/add');//创建
        Route::post('modify', 'DeliverLine/edit');//修改
        Route::post('details', 'DeliverLine/detail');//详情
        Route::post('modify_status', 'DeliverLine/editStatus');//修改状态
        Route::post('del', 'DeliverLine/del');//删除
        Route::post('select', 'DeliverLine/search');//查询
        Route::post('store_create', 'DeliverLine/addStore');//添加
        Route::post('store_del', 'DeliverLine/delStore');//删除
    });
    //运单管理(司机任务)
    Route::group('task', function () {
        Route::post('list', 'DeliverTask/list');//列表
        Route::post('create', 'DeliverTask/add');//创建
        Route::post('modify', 'DeliverTask/edit');//修改
        Route::post('details', 'DeliverTask/detail');//详情
        Route::post('modify_status', 'DeliverTask/editStatus');//修改状态
        Route::post('del', 'DeliverTask/del');//删除
        Route::post('select', 'DeliverTask/search');//查询
        Route::post('order', 'DeliverTask/orderList');//销售单查询
    });
})->middleware(Token::class);

//分拣单
Route::group('picking', function () {
    //门店
    Route::group('store', function () {
        Route::post('list', 'PickingStore/list');//列表
        Route::post('modify', 'PickingStore/edit');//修改
        Route::post('details', 'PickingStore/detail');//详情
        Route::get('dow', 'PickingStore/editStatus')->append(['is_dow' => 1]);//下载
        Route::get('print', 'PickingStore/editStatus')->append(['is_print' => 1]);//打印
        Route::post('del', 'PickingStore/del');//删除
        Route::post('select', 'PickingStore/search');//查询
    });
    //路线
    Route::group('line', function () {
        Route::post('list', 'PickingLine/list');//列表
        Route::post('details', 'PickingLine/detail');//详情
        Route::get('dow', 'PickingLine/editStatus')->append(['is_dow' => 1]);//下载
        Route::get('print', 'PickingLine/editStatus')->append(['is_print' => 1]);//打印
        Route::post('del', 'PickingLine/del');//删除
    });
    //商品
    Route::group('goods', function () {
        Route::post('list', 'PickingGoods/list');//列表
        Route::post('modify', 'PickingGoods/edit');//修改
        Route::post('details', 'PickingGoods/detail');//详情
        Route::get('dow', 'PickingGoods/editStatus')->append(['is_dow' => 1]);//下载
        Route::get('print', 'PickingGoods/editStatus')->append(['is_print' => 1]);//打印
        Route::post('del', 'PickingGoods/del');//删除
    });
})->middleware(Token::class);

//财务管理
Route::group('account', function () {
    //司机
    Route::group('driver', function () {
        Route::post('list', 'DeliverDriver/amount');//账户列表
        Route::post('withdraw', 'DeliverDriver/withdraw');//提现
        Route::post('withdraw_list', 'DeliverDriverWithdraw/list');//账户列表
        Route::get('reject', 'DeliverDriverWithdraw/editStatus')->append(['status' => 3]);//审核拒绝
        Route::get('pass', 'DeliverDriverWithdraw/editStatus')->append(['status' => 2]);//账户审核同意
    });
    //分红设置
    Route::group('dividend', function () {
        Route::post('list', 'PartnerDividend/list');//列表
        Route::post('modify', 'PartnerDividend/edit');//修改
        Route::post('del', 'PartnerDividend/del');//删除
        Route::post('dividend', 'PartnerDividend/dividend');//开始分红
        Route::post('user', 'PartnerDividend/userList');//用户分红列表
        Route::post('user_detail', 'PartnerDividend/userDividendDetail');//用户分红明细
    })->middleware(Token::class);
})->middleware(Token::class);

//商城配置
Route::group('config', function () {
    //门店
    Route::group('mini', function () {
        Route::post('modify', 'ConfigMini/edit');//修改
        Route::post('details', 'ConfigMini/detail');//详情
    });
})->middleware(Token::class);
//上传
Route::rule('upload/:action', 'upload/:action')->middleware(CheckDomain::class); //该中间件用于检测当前域名是否合法

// 订单导出
Route::group('export', function () {
    Route::post('order', 'Order/exportOrder');//订单导出
});